<?php
/**
 * bs多规格sku商城系统
 * ============================================================================
 * 版权所有 2024-2099 wltx666.com，并保留所有权利。
 * 网站地址: https://wltx666.com
 * ============================================================================
 * Author: 草上飞
 * Email: wltx@alipay168.cn
 * QQ: 2719875001
 * Date: 2024/12/15
 * 描述:
 */

namespace app\api\controller;

use app\result\HomeResult;
use app\result\SettingResult;
use app\result\UpdateResult;

class Home extends BaseIndex
{
    protected $unauthorized = ['home@index', 'home@h5_check_version', 'home@article_info', 'home@base_info'];

    public function index()
    {
        data_exit_json((new HomeResult())->index($this->param, $this->user_id));
    }

    public function h5_check_version()
    {
        $check = (new UpdateResult())->index($this->param);
        data_exit_json($check);
    }

    //文章类型详情
    public function article_info()
    {
        $key = input('key', '', 'trim');
        if (!$key) {
            data_return('参数错误', 1);
        }
        if ($key == 'service') {
            $key = 'about';
        } elseif ($key == 'register') {
            $key = 'register_agreement';
        } elseif ($key == 'privacy') {
            $key = 'privacy_agreement';
        }
        $settingResult = new SettingResult();
        $setting = $settingResult->get($key);
        if ($setting) {
            $setting['value'] = htmlspecialchars_decode($setting['value']);
        }
        data_return('success', 0, [
            'info' => $setting
        ]);
    }

    public function base_info()
    {
        $check = (new SettingResult())->base_info($this->param);
        data_exit_json($check);
    }
}
